home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / clipper / nfpat2.zip / SHADOW.ASM < prev    next >
Assembly Source File  |  1992-11-27  |  10KB  |  227 lines

  1. ; File......: SHADOW.ASM
  2. ; Author....: Ted Means
  3. ; Date......: $Date:   27 Nov 1992 10:39:18  $
  4. ; Revision..: $Revision:   1.7  $
  5. ; Log file..: $Logfile:   C:/nanfor/src/shadow.asv  $
  6. ; This is an original work by Ted Means and is placed in the
  7. ; public domain.
  8. ;
  9. ; Modification history:
  10. ; ---------------------
  11. ;
  12. ; $Log:   C:/nanfor/src/shadow.asv  $
  13. ;  
  14. ;     Rev 1.7   27 Nov 1992 10:39:18   GLENN
  15. ;  Another memory related bug fixed by Ted.
  16. ;  
  17. ;     Rev 1.6   21 Nov 1992 11:30:24   GLENN
  18. ;  Ted fixed a bug in which memory was being overwritten if the top and
  19. ;  bottom coordinates were equal.
  20. ;  
  21. ;     Rev 1.5   16 Nov 1992 00:10:26   GLENN
  22. ;  An accidental change to the interface was made when ft_shadow() was
  23. ;  rewritten.  This brings it back to the old calling convention.
  24. ;  
  25. ;     Rev 1.4   16 Oct 1992 00:07:06   GLENN
  26. ;  Just making sure we had Ted's current revision.
  27. ;  
  28. ;     Rev 1.3   28 Sep 1992 21:41:06   GLENN
  29. ;  Ted Means completely and totally rewrote this to compile under TASM's
  30. ;  IDEAL mode, with more features.  See the documentation.  It should be
  31. ;  compatible with the old Reginald Walton function, but is much faster.
  32. ;  
  33. ;     Rev 1.2   15 Aug 1991 23:07:26   GLENN
  34. ;  Forest Belt proofread/edited/cleaned up doc
  35. ;  
  36. ;     Rev 1.1   11 May 1991 00:29:22   GLENN
  37. ;  Major re-write by Ted Means.  He sped it up.  It will also cooperate
  38. ;  with Clipper's internal _gtmaxrow and _gtmaxcol settings.  
  39. ;  
  40. ;     Rev 1.0   02 Apr 1991 18:25:40   GLENN
  41. ;  Nanforum Toolkit
  42. ;
  43. ;
  44.  
  45.  
  46. ;  $DOC$
  47. ;  $FUNCNAME$
  48. ;      FT_SHADOW()
  49. ;  $CATEGORY$
  50. ;      Video
  51. ;  $ONELINER$
  52. ;      Draw a non-destructive shadow on the screen
  53. ;  $SYNTAX$
  54. ;     FT_SHADOW( <nTop>, <nLeft>, <nBottom>, <nRight> [ ,<nAttr>] ) -> NIL
  55. ;  $ARGUMENTS$
  56. ;     <nTop>    is the top row of the shadow area.
  57. ;     <nLeft>   is the upper left column of the shadow area.
  58. ;     <nBottom> is the bottom row of the shadow area.
  59. ;     <nRight>  is the lower right column of the shadow area.
  60. ;     <nAttr>   is optional and is the screen attribute to use for drawing
  61. ;               the shadow.  If not specified, the default is 8.
  62. ;  $RETURNS$
  63. ;     NIL
  64. ;  $DESCRIPTION$
  65. ;     This function allows you to implement the popular "shadow effect."  It
  66. ;     draws a shadow using the specified screen coordinates.  The shadow
  67. ;     is drawn along the bottom and right side of the specified region.
  68. ;
  69. ;     *** INTERNALS ALERT ***  This function uses several Clipper internal 
  70. ;     routines.  If using internals scares you, then stay away from this
  71. ;     function, you gutless weasel.  The use of the internals helps to make
  72. ;     the function more well-behaved.  Clipper's display context is not
  73. ;     violated -- if you use dispbegin() before drawing the shadow, it will
  74. ;     not appear until the corresponding call to dispend().  This makes for
  75. ;     much smoother screen i/o if you have several screen objects that
  76. ;     you wish to shadow.
  77. ;
  78. ;     The source code is written to TASM IDEAL mode.
  79. ;  $EXAMPLES$
  80. ;     FT_Shadow(10,10,15,50, 8)  // draw a dim shadow
  81. ;        
  82. ;     FT_Shadow(10,10,15,40,47)  // draw a green shadow
  83. ;  $END$
  84.  
  85. IDEAL                                        ; Invoke TASM IDEAL mode
  86.  
  87. Public   FT_Shadow
  88.  
  89. Extrn    __ParNI:Far
  90. Extrn    __xGrab:Far
  91. Extrn    __xFree:Far
  92. Extrn    __gtSave:Far                        ; INTERNAL!!!
  93. Extrn    __gtRest:Far                        ; INTERNAL!!!
  94. Extrn    __gtRectSize:Far                    ; INTERNAL!!!
  95.  
  96. nTop     EQU       Word Ptr BP - 2
  97. nLeft    EQU       Word Ptr BP - 4
  98. nBottom  EQU       Word Ptr BP - 6
  99. nRight   EQU       Word Ptr BP - 8
  100. nAttr    EQU       Byte Ptr BP - 10
  101. nSize    EQU       Word Ptr BP - 12
  102.  
  103. Segment  _NanFor   Word      Public    "CODE"
  104.          Assume    CS:_NanFor
  105.  
  106. Proc     FT_Shadow Far
  107.  
  108.          Push      BP                        ; Save BP
  109.          Mov       BP,SP                     ; Set up stack reference
  110.          Sub       SP,12                     ; Allocate locals
  111.  
  112.          Mov       CX,5                      ; Set param count
  113. @@Coord: Push      CX                        ; Put on stack
  114.          Call      __ParNI                   ; Retrieve param
  115.          Pop       CX                        ; Get count back
  116.          Push      AX                        ; Put value on stack
  117.          Loop      @@Coord                   ; Get next value
  118.  
  119.          Pop       [nTop]                    ; Get top coordinate
  120.          Pop       [nLeft]                   ; Get left coordinate
  121.          Pop       [nBottom]                 ; Get bottom coordinate
  122.          Pop       [nRight]                  ; Get right coordinate
  123.          Pop       [Word Ptr BP - 10]        ; Get attribute
  124.          Cmp       [nAttr],0                 ; Is attribute invalid?
  125.          JNE       @@Right                   ; If not, continue
  126.          Mov       [nAttr],8                 ; Default attribute to 8
  127.  
  128. @@Right: Mov       AX,[nBottom]              ; Load bottom coordinate
  129.          Sub       AX,[nTop]                 ; Subtract top
  130.          JZ        @@Bottom                  ; If no room, skip right side
  131.  
  132.          LEA       AX,[nSize]                ; Get size address
  133.          Push      SS                        ; Put segment on stack
  134.          Push      AX                        ; Put offset on stack
  135.  
  136.          Mov       AX,[nTop]                 ; Load top coordinate
  137.          Inc       AX                        ; Drop down a row
  138.          Mov       BX,[nBottom]              ; Load bottom coordinate
  139.          Inc       BX                        ; Drop down a row
  140.          Mov       CX,[nRight]               ; Load right coordinate
  141.          Inc       CX                        ; Move over one
  142.          Mov       DX,CX                     ; Copy to DX
  143.          Inc       DX                        ; Move over another one
  144.  
  145.          Push      DX                        ; Put right coord on stack
  146.          Push      BX                        ; Put bottom coord on stack
  147.          Push      CX                        ; Put left coord on stack
  148.          Push      AX                        ; Put top coord on stack
  149.          Call      __gtRectSize              ; Get size
  150.          
  151.          Push      [nSize]                   ; Put size on stack
  152.          Call      __xGrab                   ; Allocate memory
  153.          Add       SP,2                      ; Realign stack
  154.  
  155.          Mov       [Word Ptr BP - 14],DX     ; Reset segment
  156.          Mov       [Word Ptr BP - 16],AX     ; Reset offset
  157.          Call      __gtSave                  ; Save screen image
  158.  
  159.          Mov       CX,[nSize]                ; Get size
  160.          SHR       CX,1                      ; Divide by 2
  161.          Mov       AL,[nAttr]                ; Load attribute
  162.          LES       BX,[DWord Ptr BP - 16]    ; Load buffer pointer
  163.          Inc       BX                        ; Point to attribute byte
  164. @@RAttr: Mov       [Byte Ptr ES:BX],AL       ; Store attribute
  165.          Add       BX,2                      ; Adjust offset
  166.          Loop      @@RAttr                   ; Do next byte
  167.  
  168.          Call      __gtRest                  ; Put shadowed image onscreen
  169.          Add       SP,8                      ; Remove params from stack
  170.          Call      __xFree                   ; Free buffer
  171.          Add       SP,4                      ; Realign stack
  172.  
  173. @@Bottom:Mov       AX,[nRight]               ; Load right coordinate
  174.          Sub       AX,[nLeft]                ; Subtract top
  175.          Cmp       AX,2                      ; Enough room for shadow?
  176.          JB        @@Done                    ; If not, skip it
  177.  
  178.          LEA       AX,[nSize]                ; Get size address
  179.          Push      SS                        ; Put segment on stack
  180.          Push      AX                        ; Put offset on stack
  181.  
  182.          Mov       AX,[nBottom]              ; Load bottom coordinate
  183.          Inc       AX                        ; Drop down a row
  184.          Mov       BX,AX                     ; Copy to BX
  185.          Mov       CX,[nLeft]                ; Load left